

/**
	Author	    : Rohan
	Date	    : July 5th 2004
	Description : The procedure checks of the given product exists in the system and returns
		      the status using the out parameter.
	Usage       : 
		      	begin
		      	declare @product_exists int
	              	exec sp_check_product_exists 'product name', @product_exists
		      	if( @product_exists = 1 )
		      	begin
				print 'Product Exists'	  
	              	end
		      	else
		      	begin
				print 'Product is not existing in the system'
		      	end
*/
create proc sp_check_product_exists
(
@part_number varchar(50),
@exists      int OUT
)
as
begin

declare @product_id int
select @product_id = product_id from Product where Part_number = @part_number and P_Marketing_Part_Number is not null
if( @@rowcount = 0 )
begin
	--Product is not existing
	set @exists = 0 
end
else
begin
	--Product is existing in the database
	set @exists = 1
end

end --End of proc
